// Relative corner to absolute corner - Version 1.1

// After tracking, corner pin points are created relative to a changing
// position for the layer. This script subtracts off the position changes
// so that only corner points are moving, making the motion easier to edit.

// To use, place the layer which was pinned in popup 1.

//      LAYER                                                                 PROPERTY                     CHANNEL
//      ------                                                                ----------                     --------
// 1: Layer with corner pin points applied by tracker   doesn't matter               doesn't matter
// 2: doesn't matter                                                    doesn't matter               doesn't matter

if (time() == start_time) {
	init_pos = value(pop_layer(1), position);

} else {
	delta_pos = value(pop_layer(1), position) - init_pos;
	
	value(pop_layer(1), position) = init_pos;

  // assumes that corner pin is the first effect applied to the layer
	effect_value(pop_layer(1), 0, 1) = effect_value(pop_layer(1), 0, 1) + delta_pos;
	effect_value(pop_layer(1), 0, 2) = effect_value(pop_layer(1), 0, 2) + delta_pos;
	effect_value(pop_layer(1), 0, 3) = effect_value(pop_layer(1), 0, 3) + delta_pos;
	effect_value(pop_layer(1), 0, 4) = effect_value(pop_layer(1), 0, 4) + delta_pos;
}